#ifndef __VIDEODECODER_H__
#define __VIDEODECODER_H__

#include "pch.h"

using DecodedImageCallback = std::function<void(std::shared_ptr<ImageInfo>)>;

class VideoDecoder
{
public:
    void Init(const std::string &rtsp_url, const int32_t gpu_idx = 0, const int32_t core_idx = -1);

    void Start();
    void Stop();

    void SetImageCallback(DecodedImageCallback func);

    uint32_t ReconnectTimes();

private:
    void DecodeThread();

private:
    bool _start = false;
    DecodedImageCallback _image_callback = nullptr;

    std::string _rtsp_url = "";

    int32_t _gpu_idx = 0;

    int32_t _core_idx = -1;

    uint32_t _reconnect_times = 0;

    cudaStream_t _cuda_stream = nullptr;
    NppStreamContext _npp_stream_ctx;

    std::shared_ptr<std::thread> _thread = nullptr;
};

#endif // __VIDEODECODER_H__